package com.yzd.learnjava.util;

import java.util.Arrays;
import java.util.Collection;

public class PPrint {
	public static String pformat(Collection<?> c) {
		if(c.size() == 0) {
			return "[]";
		}
		StringBuilder builder = new StringBuilder("[");
		for(Object object : c) {
			if(c.size() != 1) {
				builder.append("\n ");
			}
			builder.append(object);
		}
		if(c.size() != 1) {
			builder.append("\n");
		}
		builder.append("]");
		return builder.toString();
	}
	
	public static void pprint(Collection<?> c) {
		Print.print(pformat(c));
	}
	
	public static void pprint(Object[] c) {
		Print.print(pformat(Arrays.asList(c)));
	}
}
